//+------------------------------------------------------------------+
//|                                                   Pricelabel.mq4 |
//|                                                            Rob54 |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Rob54"


#property indicator_chart_window

extern int BarCount=500;
extern double Width = 1.0;
extern bool DirectionLeft=true;
extern color HighColor=MidnightBlue;
extern color LowColor=Red;

int count;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
    
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   for (int i=0; i<count;i++){
      ObjectDelete("price_label"+i);
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
//----

   deinit();
   count=0;
         
   if(Width>5){
      Width=1;
   }
   
   for (int i=3; i<BarCount;i++){
   
      if (High[i]>High[i+1]&&High[i]>High[i+2]&&High[i]>High[i-1]&&High[i]>High[i-2]){
   
         ObjectCreate("price_label"+count, OBJ_ARROW, 0, Time[i], High[i]);
         ObjectSet("price_label"+count,OBJPROP_COLOR,HighColor);
   
         if(DirectionLeft==true){
            ObjectSet("price_label"+count,OBJPROP_ARROWCODE,SYMBOL_LEFTPRICE);
         }
         else{
            ObjectSet("price_label"+count,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
         }
            ObjectSet("price_label"+count, OBJPROP_WIDTH, Width);
      
         count++;
      
      }
   
      if (Low[i]<Low[i+1]&&Low[i]<Low[i+2]&&Low[i]<Low[i-1]&&Low[i]<Low[i-2]){
      
         ObjectCreate("price_label"+count, OBJ_ARROW, 0, Time[i], Low[i]);
         ObjectSet("price_label"+count,OBJPROP_COLOR,LowColor);
   
         if(DirectionLeft==true){
            ObjectSet("price_label"+count,OBJPROP_ARROWCODE,SYMBOL_LEFTPRICE);
         }
         else{
            ObjectSet("price_label"+count,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
         }
            ObjectSet("price_label"+count, OBJPROP_WIDTH, Width);
         
         count++;
   
      }
      
   }
        
//----
   return(0);
  }
//+------------------------------------------------------------------+